<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>yukari world</title>
<#include "/lib/base_source.ftl">
<style type="text/css">
</style>
</head>
<body>
<div class='whole-container'>
<#include "/lib/header.ftl">
    <div>
        <ul class="breadcrumb">
        	<li>歌曲管理</li><span class="divider">/</span>
            <li>添加会唱歌曲</li>
        </ul>
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="container span12">
            <#include "/lib/alert.ftl">

                <div class='main-content'>
                    <div class="well form-horizontal">
                        <div class='main-action'>
                        	<form id="addForm" action="${rc.contextPath}/admin/music/add" method="post">
                        		<div class="control-group">
	                                <label class="control-label">歌曲名</label>
	                                <div class="controls">
										<input id="name" type="text" name="name" />
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label">类型</label>
	                                <div class="controls">
										<select name="type" id="type">
				                        	<option value="动画/游戏">动画/游戏</option>
				                        	<option value="中文">中文</option>
				                        	<option value="V家">V家</option>
				                        	<option value="缘创">缘创</option>
				                        	<option value="英文">英文</option>
				                        	<option value="其它">其它</option>
				                        	<option value="广告">广告</option>
				                        	<option value="未分类">未分类</option>
				                        </select>
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label">中文名</label>
	                                <div class="controls">
										<input id="nameCn" type="text" name="nameCn" />
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label">备注</label>
	                                <div class="controls">
										<input id="description" type="text" name="description" />
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label">歌词</label>
	                                <div class="controls">
	                                	<span class="btn btn-success fileinput-button">
								            <span>上传</span>
		                                	<input type="file" name="file" id="file" onchange="parseLrc()"/>
								        </span>
								        <span id="uploadStatus" style="color:red;">
								        	可上传解析lrc、txt等文本文件，要求每行一句歌词
								        </span>
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label"></label>
	                                <div class="controls">
										<textarea id="content" name="content" cols="50" rows="20" style="margin: 0px; width: 20%; height: 200px;"></textarea>
	                                </div>
	                            </div>
                        		<div class="control-group">
	                                <label class="control-label"></label>
	                                <div class="controls">
										<input class="btn btn-primary btn-sm" type="submit" value="添加"/>
	                                </div>
	                            </div>
                			</form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
	var parseFlag = true;
	function parseLrc(){
		if (parseFlag){
			parseFlag = false;
			var formData = new FormData();
			formData.append("file",$("#file")[0].files[0]);
			$.ajax({ 
				url : "${rc.contextPath}/admin/file/parseLrc", 
				type : 'POST', 
				data : formData, 
				processData : false, 
				contentType : false,
				beforeSend:function(){
					$("#uploadStatus").html("正在解析，请稍后...")
				},
				success : function(result) {
					$("#content").html(result.data);
					$("#uploadStatus").html("解析成功")
					parseFlag = true;					
				}, 
				error : function(responseStr) { 
					$("#uploadStatus").html("解析失败")
					parseFlag = true;
				} 
			});
		}
		
	}

</script>
</body>
</html>